﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace danalyser.Interface.Dialogs
{
    // Свойства
    using danalyser.Properties;

    /// <summary>
    /// Форма настройки открытия с помощью внешнего редактора
    /// </summary>
    public partial class OpenWithForm : Form
    {
        public OpenWithForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Обзор
        /// </summary>
        private void browseB_Click(object sender, EventArgs e)
        {
            selectExe.FileName = "";
            if ((selectExe.ShowDialog() != DialogResult.Cancel) && File.Exists(selectExe.FileName))
                exePath.Text = selectExe.FileName;
        }

        /// <summary>
        /// Клик по кнопке "ОК"
        /// </summary>
        private void okB_Click(object sender, EventArgs e)
        {
            Settings.Default.OpenWithExecutable = exePath.Text;
            Settings.Default.OpenWithCmd = cmdLine.Text;
            Settings.Default.Save();
            this.Close();
        }

        /// <summary>
        /// Отображение формы
        /// </summary>
        private void OpenWithForm_Shown(object sender, EventArgs e)
        {
            exePath.Text = Settings.Default.OpenWithExecutable;
            cmdLine.Text = Settings.Default.OpenWithCmd;
        }
    }
}
